import {  Outlet } from "react-router-dom";

const ModulesFile = require.context('./', false, /.js$/)
// 总路由集合
const RouterMap = []
ModulesFile.keys().map((item) => {
    //文件名
    const ModuleName = item.replace(/^.\/(.*)\.js/, '$1')
    //不包含当前index.js 文件
    if (ModuleName !== 'index') {
        //请求列表
        const ModuleList = ModulesFile(item)

        //追加到数组
        RouterMap.push(...ModuleList.default);
    }

})
//默认父组件 可以自己定义
const layout = () => {
    return (
      <>
        <Outlet />
      </>
    )
  }
const RouterList = [
{
    path: '/business',
    component: layout,
    children: RouterMap,
}
]
  
  export default RouterList